home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / LSPSPR.ZIP / LSP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-19  |  1.4 KB  |  83 lines

  1. #ifndef  _LSP_TABLE
  2. #define  _LSP_TABLE
  3.  
  4. #define  MAX 64
  5.  
  6.  
  7. #define  swap(A,B) {A^=B; B^=A; A^=B; }
  8.  
  9.  
  10. typedef  struct {
  11.     int length;
  12.     unsigned char *address;
  13. }   LSP;
  14.  
  15.  
  16. LSP      *node[200],*temp;
  17.  
  18.  
  19. void     AddLSPMark(int x,int y,int length,unsigned char *address)
  20. {
  21.     int  loop;
  22.     LSP  *source,*target;
  23.  
  24.     if( (unsigned)y>=(unsigned)200 || \
  25.         x+length<0 || x>=320 || length<=0 ) return ;
  26.  
  27.     if( x<0 ) {
  28.         address-=x;
  29.         length+=x;
  30.         x=0;
  31.     }
  32.  
  33.     if( x+length >= 320 ) {
  34.         length=320-x;
  35.     }
  36.  
  37.     source=node[y];
  38.     target=temp;
  39.  
  40.     for(loop=0;loop<x;target++,source++) {
  41.         loop+=source->length;
  42.         memcpy(target,source,sizeof(LSP));
  43.     }
  44.  
  45.     target--;
  46.     target->length-=loop-x;
  47.     target++;
  48.  
  49.     target->length=length;
  50.     target->address=address;
  51.     target++;
  52.  
  53.     for(;loop<=x+length;source++) loop+=source->length;
  54.     source--;
  55.  
  56.     target->length=loop-(x+length);
  57.     target->address=source->address+(x+length)-(loop-source->length);
  58.     target++;
  59.     source++;
  60.  
  61.     for(;loop<320;target++,source++) {
  62.         loop+=source->length;
  63.         memcpy(target,source,sizeof(LSP));
  64.     }
  65.  
  66.     swap((long)node[y],(long)temp);
  67. }
  68.  
  69.  
  70. void     SetNode(void)
  71. {
  72.     int  loop;
  73.  
  74.     for(loop=0;loop<200;loop++) node[loop]=malloc(sizeof(LSP)*MAX);
  75.     temp=malloc(sizeof(LSP)*MAX);
  76. }
  77.  
  78.  
  79. #endif
  80.  
  81.  
  82. // IDEA : neolith
  83. // CODE : NOERROR / GARGOYLE